<?php
    // Start session
    session_start();
    // Check the session
    if(!isset($_SESSION['user_id']) || $_SESSION['user_id'] == '')
    {
        header('Location:index.php?status=EXP');
        die();
    }
    include "gestionAdmin.php";
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Facturas del proyecto</title>
    <!-- Bootstrap core CSS -->
    <link href="bootstrap/css/bootstrap.css" rel="stylesheet">
  </head>

  <body>
    <!-- Main bar on top -->
    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="navbar-header">
            <a class="navbar-brand" href="menuDirectivo.php"><span class="glyphicon glyphicon-home"></span> Menú principal </a>
        </div>
        <div class="navbar-header navbar-right">
            <a href="index.php" class="btn btn-info" role="button">Cerrar Sesión</a>
        </div>
    </div>

    <!-- Main jumbotron -->
    <div class="jumbotron">
      <div class="container">
        <h1><span class="glyphicon glyphicon-file"></span> Facturas del proyecto</h1>
        <p class="text-primary">Aquí se muestran las facturas del proyecto seleccionado. </p>
      </div>
    </div>

    <div class="container">

      <div class="row">
        <div class="col-md-12">
            <h1>Facturas</h1>
            <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
        </div>
      </div><!-- End of row -->

      <hr>

      <footer>
        <p>&copy; <b>Dash HR</b> Derechos Reservados ® 2013</p>
      </footer>
    </div> <!-- /container -->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    <script src="http://code.highcharts.com/modules/exporting.js"></script>
    <script type="text/javascript">
$(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Facturas del proyecto'
        },
        tooltip: {
    	    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Facturas',
            data: 
            [
            <?php
                $datos = dimeFacturasProyecto($_REQUEST['idProyecto']);
                $primero = TRUE;
                foreach($datos as $fila)
                {
                    if($primero)
                    {
                        $primero = FALSE;
                    }
                    else
                    {
                        echo ',';
                    }
                    echo "['Factura " . $fila['folio'] . "',   " . $fila['monto'] . "]";
                }   
                /*
                ['Firefox',   45.0],
                ['IE',       26.8],
                {
                    name: 'Chrome',
                    y: 12.8,
                    sliced: true,
                    selected: true
                },
                ['Safari',    8.5],
                ['Opera',     6.2],
                ['Others',   0.7]
                */ 
            ?>
            ]
        }]
    });
});
    </script>
  </body>
</html>
